home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: August, 2002
- //
- // Description:
- // This script provides an option box dialog for
- // restricting the constrained axes.
- //
- // Input Arguments:
- // boolean showOptionBox true - show the option box dialog
- // false - just execute the command
- //
- // Procedure Name:
- // setOptionVars
- //
- // Description:
- // Initialize the option values.
- //
- // Input Arguments:
- // Whether to set the options to default values.
- //
- // Return Value:
- // None.
- //
- proc setOptionVars(int $forceFactorySettings)
- {
- if ($forceFactorySettings ||
- !`optionVar -exists restrictConstraintX`) {
- optionVar -intValue restrictConstraintX 1;
- }
- if ($forceFactorySettings ||
- !`optionVar -exists restrictConstraintY`) {
- optionVar -intValue restrictConstraintY 1;
- }
- if ($forceFactorySettings ||
- !`optionVar -exists restrictConstraintZ`) {
- optionVar -intValue restrictConstraintZ 1;
- }
-
- // maintain existing offset
- //
- if ($forceFactorySettings ||
- !`optionVar -exists restrictAxisMaintainOffset`) {
- optionVar -intValue restrictAxisMaintainOffset 0;
- }
- }
-
- //
- // Procedure Name:
- // restrictAxesSetup
- //
- // Description:
- // Update the state of the option box UI to reflect the option values.
- //
- // Input Arguments:
- // parent - Top level parent layout of the option box UI.
- // Required so that UI object names can be
- // successfully resolved.
- //
- // forceFactorySettings - Whether the option values should be set to
- // default values.
- //
- // Return Value:
- // None.
- //
- global proc restrictAxesSetup(string $parent, int $forceFactorySettings)
- {
- // Retrieve the option settings
- //
- setOptionVars($forceFactorySettings);
-
- setParent $parent;
-
- checkBoxGrp -edit -value1 `optionVar -query restrictConstraintX` restrictXWidget;
- checkBoxGrp -edit -value1 `optionVar -query restrictConstraintY` restrictYWidget;
- checkBoxGrp -edit -value1 `optionVar -query restrictConstraintZ` restrictZWidget;
-
- checkBoxGrp -edit -value1 `optionVar -query restrictAxisMaintainOffset` restrictAxisMaintainWidget;
- }
-
- //
- // Procedure Name:
- // restrictAxesCallback
- //
- // Description:
- // Update the option values with the current state of the option box UI.
- //
- // Input Arguments:
- // parent - Top level parent layout of the option box UI. Required so
- // that UI object names can be successfully resolved.
- //
- // doIt - Whether the command should execute.
- //
- // Return Value:
- // None.
- //
- global proc restrictAxesCallback(string $parent, int $doIt)
- {
- setParent $parent;
-
- // Set the optionVar's from the control values, and then
- // perform the command.
-
- optionVar -intValue restrictConstraintX `checkBoxGrp -query -value1 restrictXWidget`;
- optionVar -intValue restrictConstraintY `checkBoxGrp -query -value1 restrictYWidget`;
- optionVar -intValue restrictConstraintZ `checkBoxGrp -query -value1 restrictZWidget`;
-
- // maintain offset
- //
- optionVar -intValue restrictAxisMaintainOffset `checkBoxGrp -query -value1 restrictAxisMaintainWidget`;
-
- if ($doIt) {
- performModifyConstraintAxes 0;
- addToRecentCommandQueue "performModifyConstraintAxes 0" "ModifyConstraintAxes";
- }
- }
-
- //
- // Procedure Name:
- // restrictAxesOptions
- //
- // Description:
- // Construct the option box UI. Involves accessing the standard option
- // box and customizing the UI accordingly.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // None.
- //
- proc restrictAxesOptions()
- {
- // Name of the command for this option box.
- //
- string $commandName = "restrictAxes";
-
- // Build the option box actions.
- //
- string $callback = ($commandName + "Callback");
- string $setup = ($commandName + "Setup");
-
- // Get the option box.
- //
- string $layout = getOptionBox();
- setParent $layout;
-
- // Pass the command name to the option box.
- //
- setOptionBoxCommandName($commandName);
-
- // Activate the default UI template.
- //
- setUITemplate -pushTemplate DefaultTemplate;
-
- // Turn on the wait cursor.
- //
- waitCursor -state 1;
-
- tabLayout -scr true -tv false;
- string $parent = `columnLayout -adjustableColumn 1`;
-
- checkBoxGrp
- -label "Constrain"
- -label1 "X"
- -annotation "Enable to make the constraint act upon the X axis."
- -numberOfCheckBoxes 1
- restrictXWidget;
-
- checkBoxGrp
- -label ""
- -label1 "Y"
- -annotation "Enable to make the constraint act upon the Y axis."
- -numberOfCheckBoxes 1
- restrictYWidget;
-
- checkBoxGrp
- -label1 "Z"
- -annotation "Enable to make the constraint act upon the Z axis."
- -numberOfCheckBoxes 1
- restrictZWidget;
-
- checkBoxGrp
- -label "Maintain Offset"
- -label1 " "
- -annotation "Preserve the current offset of the constrained objects."
- -numberOfCheckBoxes 1
- restrictAxisMaintainWidget;
-
- // Turn off the wait cursor.
- //
- waitCursor -state 0;
-
- // Deactivate the default UI template.
- //
- setUITemplate -popTemplate;
-
- // 'Apply' button.
- //
- string $applyBtn = getOptionBoxApplyBtn();
- button -edit
- -label "Modify"
- -command ($callback + " " + $parent + " " + 1)
- $applyBtn;
-
- // 'Save' button.
- //
- string $saveBtn = getOptionBoxSaveBtn();
- button -edit
- -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox")
- $saveBtn;
-
- // 'Reset' button.
- //
- string $resetBtn = getOptionBoxResetBtn();
- button -edit
- -command ($setup + " " + $parent + " " + 1)
- $resetBtn;
-
- // Set the option box title.
- //
- setOptionBoxTitle("Modify Constrained Axis Options");
-
- // Customize the 'Help' menu item text.
- //
- setOptionBoxHelpTag( "ModifyConstrainedAxis" );
-
- // Set the current values of the option box.
- //
- eval (($setup + " " + $parent + " " + 0));
-
- // Show the option box.
- //
- showOptionBox();
- }
-
- //
- // Procedure Name:
- // restrictAxesHelp
- //
- // Description:
- // Return a short description about this command.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // string.
- //
- proc string restrictAxesHelp()
- {
- return
- (" Command: Modify Constrained Axes - restrict axes a constraint.\n" + "Selection: <A target to be removed and a constrained object.>");
- }
-
- //
- // Procedure Name:
- // assembleCmd
- //
- // Description:
- // Construct the command that will apply the option box values.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // None.
- //
- proc string assembleCmd()
- {
- string $cmd = "doModifyConstraintAxes 1 ";
- setOptionVars(false);
-
- int $maintainOffset = `optionVar -q restrictAxisMaintainOffset`;
- int $cx = `optionVar -q restrictConstraintX`;
- int $cy = `optionVar -q restrictConstraintY`;
- int $cz = `optionVar -q restrictConstraintZ`;
-
- $cmd = ($cmd + " { " +
- "\""+ $cx + "\"" +
- ",\""+ $cy + "\"" +
- ",\""+ $cz + "\"" +
- ",\""+ $maintainOffset + "\"" +
- "};");
- return $cmd;
- }
-
- //
- // Procedure Name:
- // performModifyConstraintAxes
- //
- // Description:
- // Perform the constraint command using the corresponding
- // option values related to restricting the constraint axis.
- // This procedure will also show the option box
- // window if necessary as well as construct the command string
- // that will invoke the restrictAxes command with the current
- // option box values.
- //
- // Input Arguments:
- // 0 - Execute the command.
- // 1 - Show the option box dialog.
- // 2 - Return the command.
- //
- // Return Value:
- // None.
- //
- global proc string performModifyConstraintAxes(int $action)
- {
- string $cmd = "";
-
- switch ($action) {
-
- // Execute the command.
- //
- case 0:
- // Retrieve the option settings
- //
- setOptionVars(false);
-
- // Get the command.
- //
- $cmd = `assembleCmd`;
-
- // Execute the command with the option settings.
- //
- eval($cmd);
-
- break;
-
- // Show the option box.
- //
- case 1:
- restrictAxesOptions;
- break;
-
- // Return the command string.
- //
- case 2:
- // Retrieve the option settings.
- //
- setOptionVars (false);
-
- // Get the command.
- //
- $cmd = `assembleCmd`;
- break;
- }
- return $cmd;
- }
-
-